// 版权归 瞄你个汪 所有。使用本代码应遵守相关法律法规和Apache 2.0开源许可要求。
package top.geeke.toolkit;

/**
 * <p>
 * 时间格式化类
 * </p>
 * @author 瞄你个汪
 * @since 2024-01-01 12:00:00
 */
public class TimeFormatter {

    /**
     * 格式化秒单位时间为 dd天hh小时mm分mm秒
     * @param seconds 秒
     */
    public static String formatSeconds(long seconds) {  
        StringBuilder sb = new StringBuilder();  
  
        long days = seconds / (24 * 60 * 60);  
        if (days > 0) {  
            sb.append(days).append("天");  
        }  
  
        seconds %= (24 * 60 * 60);  
        long hours = seconds / (60 * 60);  
        if (hours > 0) {  
            sb.append(hours).append("小时");  
        }  
  
        seconds %= (60 * 60);  
        long minutes = seconds / 60;  
        if (minutes > 0) {  
            sb.append(minutes).append("分");  
        }  
  
        long remainingSeconds = seconds % 60;  
        if (remainingSeconds > 0) {  
            sb.append(remainingSeconds).append("秒");  
        }  

        return sb.length() == 0 ? "0秒" : sb.toString();
    }
}